package com.zrentech.order.data.dbhelper.builder;

import android.content.ContentValues;
import android.database.Cursor;

import com.zrentech.order.data.busibean.TableBean;
import com.zrentech.order.data.dbhelper.DatabaseBuilder;

/**
 * 
 * 提供关于台位的创建和解析方面的功能
 * 
 * @author Leon
 */

public class TableDBuilder extends DatabaseBuilder<TableBean> {

	public static final String TRACK_ID = "id";
	public static final String TRACK_TYPEID = "typeid";
	public static final String TRACK_NUMBER = "number";
	public static final String TRACK_NAME = "name";
	public static final String TRACK_STATUS = "status";
	public static final String TRACK_DESC = "desc";

	@Override
	public TableBean build(Cursor query) {
		int columnId = query.getColumnIndex(TRACK_ID);
		int columnTypeID = query.getColumnIndex(TRACK_TYPEID);
		int columnNumber = query.getColumnIndex(TRACK_NUMBER);
		int columnName = query.getColumnIndex(TRACK_NAME);
		int columnStatus = query.getColumnIndex(TRACK_STATUS);
		int columnDesc = query.getColumnIndex(TRACK_DESC);

		TableBean table = new TableBean();
		table.setId(query.getInt(columnId));
		table.setTypeid(query.getInt(columnTypeID));
		table.setNumber(query.getInt(columnNumber));
		table.setName(query.getString(columnName));
		table.setStatus(query.getInt(columnStatus));
		table.setDesc(query.getString(columnDesc));
		return table;
	}

	@Override
	public ContentValues deconstruct(TableBean track) {
		ContentValues values = new ContentValues();
		values.put(TRACK_ID, track.getId());
		values.put(TRACK_TYPEID, track.getTypeid());
		values.put(TRACK_NUMBER, track.getNumber());
		values.put(TRACK_NAME, track.getName());
		values.put(TRACK_STATUS, track.getStatus());
		values.put(TRACK_DESC, track.getDesc());
		return values;
	}

}
